Skip to content

Fix synced mobile books opening with stale file paths#447

Open
codedogQBY wants to merge 1 commit into
mainfrom
codex/fix-mobile-synced-book-file-path
Open

Fix synced mobile books opening with stale file paths#447
codedogQBY wants to merge 1 commit into
mainfrom
codex/fix-mobile-synced-book-file-path

Conversation

@codedogQBY

Copy link
Copy Markdown
Owner

Analysis

Issue #314 reports Android books failing to open, and the diagnostic log repeatedly shows the reader WebView failing with Error: File not found immediately after sync/download activity.

The sync database payload can bring a books.file_path and sync_status from another device. If that source device stored the file as local, the receiving device could also mark the book as local even when the file has not been downloaded to this device yet. For source-device absolute or file:// paths, the mobile reader then asks its local HTTP server for a path that does not exist under the current app data directory.

Changes

  • Normalize synced book file paths to the managed local form books/{bookId}.{ext} when applying remote book records.
  • Treat synced-in book records as remote until the current device confirms or downloads the file locally.
  • Download on-demand books into the managed local path even if the DB row contains a stale source-device absolute path.
  • Update the DB filePath and syncStatus together after a successful on-demand download.
  • Mark an already-present local synced file back to local during file sync.
  • Add targeted sync tests for localized remote paths and absolute source-device download paths.

Verification

  • pnpm --filter @readany/core test -- sync-files simple-sync.integration
  • pnpm --filter @readany/core exec tsc --noEmit
  • pnpm exec biome check packages/core/src/sync/local-book-paths.ts packages/core/src/sync/simple-sync.ts packages/core/src/sync/sync-files.ts packages/core/src/sync/__tests__/simple-sync.integration.test.ts packages/core/src/sync/__tests__/sync-files.test.ts
  • git diff --check

Fixes #314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 打不开

1 participant